﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using HotelUI.Models;
using IHodelBll;
using Model;


namespace HotelUI.Controllers
{
    public class RecreationController : Controller
    {

        IHodelBll.IRecreationsBlls bll;
        public RecreationController(IRecreationsBlls _bll)
        {
            bll = _bll;
        }

        /// <summary>
        /// 返回视图
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult RecreationShows()
        {
            return View();
        }
        /// <summary>
        /// 显示获取值
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet]
        public List<Recreation> RecreationShow(string name)
        {
            List<Recreation> list = bll.RecreationShow();
            if (!string.IsNullOrEmpty(name))
            {
                list = list.Where(c => c.Rprincipal.Contains(name)).ToList();
            }
            return list;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Del(int id)
        {
            return bll.Del(id);

        }
        /// <summary>
        /// 添加返回视图
        /// </summary>
        /// <returns></returns>
        public IActionResult AddAmusementview()
        {
            return View();

        }

        /// <summary>
        /// 添加娱乐项目
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpPost]
        public int AddAmusement(Amusement m)
        {
            return bll.AddAmusement(m);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpPost]
        public int AddRecren(Recreationlist m)
        {
            return bll.AddRecren(m);
        }
        /// <summary>
        /// 显示娱乐列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<Amusement> AmusementShow()
        {
            List<Amusement> list = bll.AmusementShow();
            return list;

        }
        /// <summary>
        /// 修改页面返回视图
        /// </summary>
        /// <returns></returns>
        public IActionResult UptRecreationView()
        {
            return View();

        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public Recreationlist Recreation(int id)
        {
            return bll.Find(id);
        
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpPost]
        public int UptRecreation(Recreationlist m)
        {
            return bll.UptRecreation(m);
        }
        /// <summary>
        /// 删除娱乐项目
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Delam(int id)
        {
            return bll.Delam(id);
        
        }
    }
}
